package com.ben.tcptester.Entity;

import io.netty.channel.Channel;

/**
 * Created by Peter on 2017/7/17.
 */
public class Client {
    private String id;
    private String name;
    private Channel channel;

    public Client (String clientId){
        this.id = clientId;
    }

    public Client(Channel channel) {
        this.id = channel.id().asLongText();
        this.name = channel.localAddress().toString();
        this.channel = channel;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Client client = (Client) o;

        return id.equals(client.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}
